package com.example.xianji.activity;

import android.os.Bundle;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;

import com.example.xianji.R;
import com.example.xianji.constant.Constant;
import com.example.xianji.utils.sp.PreferenceEngine;

public class Main_XuQiu_GuanLiActivity extends Activity implements OnClickListener {
    /***************************需求管理页面**************************************/
    private RelativeLayout xuqiu_guanli_back;
    private RelativeLayout relativelayout_send_xuqiu, relativelayout_my_xuqiu, relativelayout_my_duijie_xuqiu,
            relativelayout_zuanjia_xuqiu, relativelayout_my_xuqiu_collection, relativelayout_my_xuqiu_question, relativelayout_my_receive_xuqiu_question;
//    private SharedPreferences sp;
//    private Editor ed;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }
        setContentView(R.layout.activity_main__xu_qiu__guan_li);
        //	MyApplication.getInstance().addActivity(this);
        xuqiu_guanli_back = (RelativeLayout) findViewById(R.id.xuqiu_relative_guanli_back);
        relativelayout_send_xuqiu = (RelativeLayout) findViewById(R.id.relativelayout_send_xuqiu);
        relativelayout_my_xuqiu = (RelativeLayout) findViewById(R.id.relativelayout_my_xuqiu);
        relativelayout_my_duijie_xuqiu = (RelativeLayout) findViewById(R.id.relativelayout_my_duijie_xuqiu);
        relativelayout_zuanjia_xuqiu = (RelativeLayout) findViewById(R.id.relativelayout_zuanjia_xuqiu);
        relativelayout_my_xuqiu_collection = (RelativeLayout) findViewById(R.id.relativelayout_my_xuqiu_collection);
        relativelayout_my_xuqiu_question = (RelativeLayout) findViewById(R.id.relativelayout_my_xuqiu_question);
        relativelayout_my_receive_xuqiu_question = (RelativeLayout) findViewById(R.id.relativelayout_my_receive_xuqiu_question);
//        sp = getSharedPreferences("text", MODE_PRIVATE);
//        ed = sp.edit();
        if (PreferenceEngine.getInstance().getInt(Constant.SP.NAME, Constant.SP.KEY_EXPERT, 0) == 0) {
            relativelayout_zuanjia_xuqiu.setVisibility(View.GONE);
        } else if (PreferenceEngine.getInstance().getInt(Constant.SP.NAME, Constant.SP.KEY_EXPERT, 0) == 1) {
            relativelayout_zuanjia_xuqiu.setVisibility(View.VISIBLE);
        }
        xuqiu_guanli_back.setOnClickListener(this);
        relativelayout_send_xuqiu.setOnClickListener(this);
        relativelayout_my_xuqiu.setOnClickListener(this);
        relativelayout_my_duijie_xuqiu.setOnClickListener(this);
        relativelayout_zuanjia_xuqiu.setOnClickListener(this);
        relativelayout_my_xuqiu_collection.setOnClickListener(this);
        relativelayout_my_xuqiu_question.setOnClickListener(this);
        relativelayout_my_receive_xuqiu_question.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.xuqiu_relative_guanli_back) {
            this.finish();
        } else if (v.getId() == R.id.relativelayout_send_xuqiu) {
            //发布需求
            startActivity(new Intent(Main_XuQiu_GuanLiActivity.this, Main_Send_XuQiuActivity.class));
        } else if (v.getId() == R.id.relativelayout_my_xuqiu) {
            //我发布的需求
            startActivity(new Intent(Main_XuQiu_GuanLiActivity.this, Main_My_XuQiuActivity.class));
        } else if (v.getId() == R.id.relativelayout_my_duijie_xuqiu) {
            //我对接的需求
            Intent intent = new Intent(Main_XuQiu_GuanLiActivity.this, Main_My_DuiJieActivity.class);
            intent.putExtra("duijie", 1);
            startActivity(intent);
        } else if (v.getId() == R.id.relativelayout_zuanjia_xuqiu) {

            startActivity(new Intent(Main_XuQiu_GuanLiActivity.this, Main_Expert_XuQiuTingActivity.class));
        } else if (v.getId() == R.id.relativelayout_my_xuqiu_collection) {
            //我收藏的需求页面
            Intent intent = new Intent(this, Main_My_CollectionActivity.class);
            intent.putExtra("collection_type", "demand");//需求
            startActivity(intent);
        } else if (v.getId() == R.id.relativelayout_my_xuqiu_question) {
            //我的提问
            startActivity(new Intent(Main_XuQiu_GuanLiActivity.this, Main_My_TiWenActivity.class));
        } else if (v.getId() == R.id.relativelayout_my_receive_xuqiu_question) {
            //我收到的提问
            startActivity(new Intent(Main_XuQiu_GuanLiActivity.this, Main_My_Receive_TiWenActivity.class));
        }
    }
}
